🎄 Christmas Word Guessing Game 🎄
We created this activity using ChatGPT, an AI tool. We've given it a quick test but it still might not work correctly. If it doesn't quite work, try to fix it!Welcome! In this project, you’ll create a fun Christmas-themed word guessing game using Python. You’ll guess letters to figure out the secret word before you run out of attempts. Let’s get started!
Step 1: Define the Word List
We’ll begin by creating a list of Christmas-themed words. This will be the source for the secret word the player has to guess. Launch a code editor like Thonny, and add this code:
What does this do?
- Creates a list called
words
containing Christmas-related words. - The game will randomly pick a word from this list for the player to guess.
🎉 Great start! You’ve created the word list. Let’s pick a word from it next!
Step 2: Randomly Select a Word
We’ll use Python’s random
library to pick a word from the list. Add this code:
What does this do?
import random
: Imports the random library for picking random elements.random.choice(words)
: Selects a random word from thewords
list and assigns it tosecret_word
.
✨ Well done! The game now picks a secret word. Let’s set up the guesses next!
Step 3: Add Emojis
Let’s make the game festive by including emojis! You don't have to do this, but if you want, you can copy emojis directly into Thonny or use your keyboard shortcut:
- On Windows: Press
Windows + .
- On Mac: Press
Cmd + Ctrl + Space
- On Linux: Copy emojis from a website like Emojipedia.
Update your game introduction like this:
🎁 Awesome! Your game now looks festive and fun. Let’s continue!
Step 4: Set Up the Guesses
We’ll prepare to track the player’s guesses by starting with blank spaces. Add this code:
What does this do?
len(secret_word)
: Gets the length of the secret word.["_"] * word_length
: Creates a list of blanks (underscores) to represent the word.attempts = 6
: Sets the number of wrong guesses the player is allowed.
🎶 Fantastic! You’ve set up the blanks and allowed guesses. Time to build the game loop!
Step 5: Create the Game Loop
We’ll create a loop that lets the player guess letters until they win or run out of attempts. Add this code:
What does this do?
while attempts > 0
: Repeats the game loop until the player runs out of attempts.- Prints the current progress of the guessed word and remaining attempts.
- Checks if the player’s guess is correct and updates the blanks accordingly.
- Ends the game if the player guesses the word or runs out of attempts.
🌟 Amazing! You’ve created the game loop. Now let’s test the game!
Step 6: Run and Test the Game
Save your code as word_guess.py
and run it in Thonny. Play the game by guessing letters. Here are some things to try:
- Guess letters to complete the word.
- Test what happens when you run out of attempts.
- Try playing multiple rounds to see the random words.
🎉 Congratulations! You’ve built a fully functional word guessing game. Great work!